import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/home.vue'),
    meta:{
      title: '喝水提醒'
    }
  },
  {
    path: '/alert',
    name: 'alert',
    component: () => import('@/views/alert.vue'),
    meta:{
      title: '提醒'
    }
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('@/views/about.vue'),
    meta:{
      title: '关于'
    }
  },

]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router

